package com.oazon.moco.link;

import java.util.ArrayList;
import java.util.List;

import com.oazon.moco.bean.Metadata;
import com.oazon.moco.lan.core.http.bean.CurrentPlayMode;
import com.oazon.moco.lan.core.http.bean.MediaStateInstance;
import com.oazon.moco.lan.core.http.bean.TransportState;
import com.oazon.moco.lan.core.http.bean.TransportURIMetaData;
import com.oazon.moco.lan.core.http.bean.Volume;

public class SaveMediaState {
	
	private static SaveMediaState saveMediaState = null;
	
	private MediaStateInstance.Instance saveMedia = null;
	private MediaStateInstance mediaStateInstance = null;
	private List<MediaStateInstance.Instance> saveMediaStates = null;

	
	private SaveMediaState(){
		saveMedia = new MediaStateInstance.Instance();
		mediaStateInstance = new MediaStateInstance();
		saveMediaStates = new ArrayList<MediaStateInstance.Instance>();
		
		saveMediaStates.add(saveMedia);
		mediaStateInstance.setInstances(saveMediaStates);
	};
	
	public static synchronized SaveMediaState getInstance(){
		
		if(saveMediaState == null){
			saveMediaState = new SaveMediaState();
		}
		return saveMediaState;
	}
	
	public synchronized MediaStateInstance getMediaStateInstance(){
		
		saveMediaStates.set(0, saveMedia);
		mediaStateInstance.setInstances(saveMediaStates);
		return mediaStateInstance;
	}
	
	public synchronized MediaStateInstance.Instance getFirstMediaStateInstance(){
		return saveMedia;
	}
	
	/**
	 * 修改第一个媒体状态MediaStateInstance.Instance
	 * @param saveMedia
	 */
	public synchronized void setMediaStateInstance(MediaStateInstance.Instance saveMedia){
		this.saveMedia = saveMedia;
		saveMediaStates.set(0, saveMedia);
	}
	
	public synchronized void addMediaStateInstance(MediaStateInstance.Instance saveMedia){
		
		saveMediaStates.add(saveMedia);
		mediaStateInstance.setInstances(saveMediaStates);
	}

	public synchronized void setCurrentItemID(String currentItemID){
		saveMedia.setCurrentItemID(currentItemID);
	}
	
	public synchronized void setCurrentServiceID(String currentServiceID) {
		saveMedia.setCurrentServiceID(currentServiceID);
	}

	public synchronized void setVolume(List<Volume> volume) {
		saveMedia.setVolume(volume);
	}

	public synchronized void setInstanceID(int instanceID) {
		saveMedia.setInstanceID(instanceID);
	}


	public synchronized void setTransportState(TransportState transportState) {
		saveMedia.setTransportState(transportState);
	}


	public synchronized void setCurrentPlayMode(CurrentPlayMode currentPlayMode) {
		saveMedia.setCurrentPlayMode(currentPlayMode);
	}


	public synchronized void setCurrentCrossfadeMode(int currentCrossfadeMode) {
		saveMedia.setCurrentCrossfadeMode(currentCrossfadeMode);
	}


	public synchronized void setNumberOfTracks(int numberOfTracks) {
		saveMedia.setNumberOfTracks(numberOfTracks);
	}


	public synchronized void setRelTime(String relTime) {
		saveMedia.setRelTime(relTime);
	}


	public synchronized void setCurrentTrack(int currentTrack) {
		saveMedia.setCurrentTrack(currentTrack);
	}


	public synchronized void setCurrentSection(int currentSection) {
		saveMedia.setCurrentSection(currentSection);
	}


	public synchronized void setCurrentTrackURI(String currentTrackURI) {
		saveMedia.setCurrentTrackURI(currentTrackURI);
	}


	public synchronized void setCurrentTrackDuration(String currentTrackDuration) {
		saveMedia.setCurrentTrackDuration(currentTrackDuration);
	}


	public synchronized void setCurrentTrackMetaData(Metadata currentTrackMetaData) {
		saveMedia.setCurrentTrackMetaData(currentTrackMetaData);
	}


	public synchronized void setNextTrackURI(String nextTrackURI) {
		saveMedia.setNextTrackURI(nextTrackURI);
	}

	public synchronized void setNextTrackMetaData(Metadata nextTrackMetaData) {
		saveMedia.setNextTrackMetaData(nextTrackMetaData);
	}


	public synchronized void setPlaybackStorageMedium(String playbackStorageMedium) {
		saveMedia.setPlaybackStorageMedium(playbackStorageMedium);
	}

	public synchronized void setAVTransportURI(String aVTransportURI) {
		saveMedia.setAVTransportURI(aVTransportURI);
	}


	public synchronized void setAVTransportURIMetaData(
			TransportURIMetaData aVTransportURIMetaData) {
		saveMedia.setAVTransportURIMetaData(aVTransportURIMetaData);
	}


	public synchronized void setCurrentTransportActions(String currentTransportActions) {
		saveMedia.setCurrentTransportActions(currentTransportActions);
	}


	public synchronized void setCurrentValidPlayModes(String currentValidPlayModes) {
		saveMedia.setCurrentValidPlayModes(currentValidPlayModes);
	}

	public synchronized TransportState getTransportState(){
		return saveMedia.getTransportState();
	}
}
